<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="layui/css/layui.css"/>
</head>
<body>
<div class="layui-fluid">
<div style="margin-top:50px;"><h2 style="color:#009688;margin-left:520px;">考勤打卡</h2><hr class="layui-bg-green"></div>
<div style="margin-top:100px;margin-left:380px;">
  <form class="layui-form">
    <div class="layui-form-item">
       <label class="layui-form-label">姓名</label>
       <div class="layui-input-inline">
         <input type="text" name="userName" id="userName" class="layui-input" th:value="${session.loginUser.userName}" readonly="readonly">
       </div>
    </div>
    
    <div class="layui-form-item">
       <label class="layui-form-label">工号</label>
       <div class="layui-input-inline">
         <input type="text" name="empNo" id="empNo" class="layui-input" th:value="${session.loginUser.account}" readonly="readonly">
       </div>
    </div>
    
    <div class="layui-form-item">
       <label class="layui-form-label">时间</label>
       <div class="layui-input-inline">
         <input type="text" name="time" id="time" class="layui-input" readonly="readonly">
       </div>
    </div>
    
    <div class="layui-form-item">
       <label class="layui-form-label">类型</label>
       <div class="layui-input-inline">
         <select name="type" id="type">
            <option value="上班">上班</option>
            <option value="下班">下班</option>
         </select>
       </div>
    </div>
    
    <div class="layui-form-item">
       <div class="layui-input-block">
         <button  class="layui-btn" lay-submit lay-filter="addAttendance">确定</button>
       </div>
    </div>
  </form>
  </div>
</div>
<script src="layui/layui.js"></script>
<script>
   layui.use('form',function(){
	   var form=layui.form;
	   var $=layui.jquery;	   
	   form.on('submit(addAttendance)',function(data){
		   $.ajax({
			   url:'/addAttendance',
			   method:'post',
			   async:false,
			   contentType:"application/json;charset=utf-8",
			   data:JSON.stringify(data.field),
			   success:function(mg){
				   if(mg){
				   layer.msg("打卡成功",{time:12000,end:function(){location.reload();}});
				  // window.setTimeut(function(){window.localtion.reload();},1500)				  
			   }else{
				   layer.msg("打卡失败");
			   }
				  
			   },
			   error:function(mg){
				  layer.msg("打卡失败");
				   window.setTimeut(function(){window.localtion.reload();},1500)
			   }
		   });
	   });
	   
	  // form.render('select');
   });
   
   layui.use('laydate',function(){
	   var laydate=layui.laydate;
	   laydate.render({
		   elem:'#time',
		   type:'datetime',
		   value:new Date(),
	   });
   });
window.reloadView=function(){
	window.location.reload();
}
setInterval('reloadView()',60000);
</script>
</body>
</html>